md5_string_utf8


描述

在密码学中,MD5(Message-Digest algorithm 5,消息摘要算法 5)是广泛使用的具有 128 位散列值的加密散列函数,并且已经在各种安全应用程序中使用。 它也常用于检查文件和字符串的完整性。 此函数将采用输入 UTF-8 字符串(其中每个字符的字节数可变)并返回该字符串唯一的由 32 个字符组成的十六进制 MD5 散列值。 In this way you can generate a secure key which can be stored and used to check the integrity of the information being sent to (or received from) an external server (for example).

NOTE: There are two formats for the MD5 encoding, UTF-8 and unicode. Both are provided to facilitate communication with different server setups, but the most common to use is unicode.


语法:

md5_string_utf8(string)


参数 描述
string 用于生成 MD5 散列的字符串。


返回:

String(字符串)


例如:

var hash, str;
str = json_encode(hiscore_map);
hash = md5_string_utf8(str);
ini_open("local.ini");
ini_write_string("info", "0", hash);
ini_close();
get[0] = http_post_string("http://www.MacSweeney Games.com/CatchTheHaggis?game_hiscores=" + string(global.game_id), str)

上面的代码将 ds_map 编码为 JSON 字符串。然后生成 MD5 散列并将其存储在 ini 文件中,以便稍后可以使用它来检查 JSON 的完整性,如果稍后从服务器接收到相同的信息,JSON 就会被发送。